package com.peiqi.aiproject.handler;

import cn.hutool.http.HttpStatus;
import com.peiqi.aiproject.domain.vo.ResponseVO;
import com.peiqi.aiproject.exception.BusinessException;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(BusinessException.class)
    public ResponseVO<Void> handlerServiceException(BusinessException e, HttpServletRequest request) {
        log.error(e.getMessages(), e);
        return ResponseVO.error(HttpStatus.HTTP_CONFLICT, e.getMessages());
    }

//    @ExceptionHandler(Exception.class)
//    public ResponseVO<Void> handelException(Exception e) {
//        return ResponseVO.error(HttpStatus.HTTP_INTERNAL_ERROR, e.getMessage());
//    }
}
